package c.x.jy.admin.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import c.x.jy.dao.entity.TeacherConfigEntity;
import c.x.jy.service.service.TeacherConfigService;
import c.x.jy.common.utils.PageUtils;
import c.x.jy.common.utils.R;



/**
 * 大师配置表
 *
 * @author amwhyh
 * @email xxx@xx.com
 * @date 2021-05-24 18:37:36
 */
@RestController
@RequestMapping("teacher/teacherconfig")
public class TeacherConfigController extends AbstractController {
    @Autowired
    private TeacherConfigService teacherConfigService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("teacher:teacherconfig:list")
    public R list(@RequestParam Map<String, Object> params){
     	if(getUser().getBusinessId()>0) {
    		params.put("businessId", getUser().getBusinessId());
    	}
        PageUtils page = teacherConfigService.queryPage(params);

        return R.put(page);
    }
    /**
     * 列表 for web
     */
    @RequestMapping("/listforweb")
    @RequiresPermissions("teacher:teacherconfig:list")
    public R listforweb(@RequestParam Map<String, Object> params){
        if(getUser().getBusinessId()>0) {
            params.put("businessId", getUser().getBusinessId());
        }
        PageUtils page = teacherConfigService.listforweb(params);

        return R.put(page);
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("teacher:teacherconfig:info")
    public R info(@PathVariable("id") Long id){
		TeacherConfigEntity teacherConfig = teacherConfigService.getById(id);

        return R.put(teacherConfig);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("teacher:teacherconfig:save")
    public R save(@RequestBody TeacherConfigEntity teacherConfig){
		teacherConfigService.save(teacherConfig);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("teacher:teacherconfig:update")
    public R update(@RequestBody TeacherConfigEntity teacherConfig){
		teacherConfigService.updateById(teacherConfig);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete/{id}")
    @RequiresPermissions("teacher:teacherconfig:delete")
    public R delete(@PathVariable("id") Long id){
		teacherConfigService.removeByIds(Arrays.asList(id));

        return R.ok();
    }

}

